﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;

namespace Data
{
    public class PhongRepository
    {
        public List<PhongDTO> GetPhongList()
        {
            List<PhongDTO> list = new List<PhongDTO>();
            try
            {
                QuanLyKhachSanEntities context = new QuanLyKhachSanEntities();
                var query = from phong in context.PhongList
                            select phong;
                foreach (var phongEF in query)
                {
                    PhongDTO phongDTO = new PhongDTO();
                    phongDTO.MaPhong = phongEF.MaPhong;
                    phongDTO.TenPhong = phongEF.TenPhong;
                    phongDTO.GhiChu = phongEF.GhiChu;
                    phongDTO.MaLoaiPhong = phongEF.MaLoaiPhong;
                    phongDTO.TinhTrang = (bool)phongEF.TinhTrang;
                    list.Add(phongDTO);
                }
            }
            catch(System.Exception)
            { 
            }
            return list;
        }
    }
}
